package kr.hkit.powerjava.chapter10;

import java.util.Arrays;
import java.util.Random;

public class LottoGenerater {
	private int[] arr;
	private static final int SIZE = 6;
	private  Random rnd;
	
	public LottoGenerater() {
		arr = new int[LottoGenerater.SIZE];
		rnd = new Random();
	}
	public void getLottoNum() {
		int num = -1;
		for(int i=0; i<arr.length; i++) {
			num = getNum();
			if(isfind(num)) {
				i--;
			} else {
				arr[i] = num;
			}
		}
	}
	public int getNum() {
		return rnd.nextInt(45)+1;
	}
	public boolean isfind(int serarchNum) {
		boolean isEquals = false;
		for(int i=0; i<arr.length; i++) {
			if(serarchNum == arr[i]) { 
				isEquals = true;
				break;
			}
		}
		return isEquals;
	}
	@Override
	public String toString() {
		return Arrays.toString(arr);
	}
	
	public static void main(String[] args) {
		LottoGenerater lo = new LottoGenerater();
		lo.getLottoNum();
		System.out.println(lo);
		
		String result = lo.isfind(30)?"Find":"Not Found";
		System.out.println(result);
	}
}